<?php 
class User extends AppModel 
{
	public $name="User";
	public $belongsTo =array('Group'); 
 	public $validate = array(
 		'username'=>array(
			'r0' => array(
        'rule'     => 'alphaNumeric',
        'required' => true,
        'message'  => 'Campo Usuario es requerido'
	    ),
		),
		'first_name'=>array(
			'r0' => array(
        'rule'     => 'alphaNumeric',
        'required' => true,
        'message'  => 'Campo Nombre es  requerido'
	    ),
		),
		'last_name'=>array(
			'r0' => array(
        'rule'     => 'alphaNumeric',
        'required' => true,
        'message'  => 'Campo Apellido es  requerido'
	    ),
		),

	);





	public function validateLogin($data)
	{
		$user = $this->find('first',array('conditions' =>array('username' => $data['username'], 'password' => $data['password'],'is_delete'=>0),'fields' =>array('id','username','group_id') ));//'fields' =>array('id', 'username'));
 		if( empty($user) == false )
        {
            return $user;
        } 
        return false;
	}
}